'   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 '           N a m e :   P L C _ E m u l a t o r _ 1 2 . t x t                                               D a t e :   2 1   O c t   2 0 2 0 
 
 '         A u t o r :   L e o n a r d o   D E   P A L O   P h . D . 
 
 '         S c o p e :   E m u l a t i n g   P L C   s e n d i n g   s e r i a l   d a t a   f o r   D i g i S c r e w   t e s t i n g . 
 
 '         P l a t e :   1 5 3 0   T X B . 
 
 '       L e n g h t :   9   -   1 2   -   1 3   -   1 4   -   1 5   -   1 6   -   1 7   -   1 8   -   1 9   -   2 2   -   2 6 
 
 '   H a r d w a r e :   U S B   t o   S e r i a l   R S 2 3 2   a d a p t e r   o r   C O M x   R S 2 3 2   c o n n e c t i o n 
 
 '           N o t e :   T o   b e   u s e d   w i t h   R e l a s e   5 . 5 . 5   o f   D i g i S c r e w 
 
 '   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 L o a d   T o c . w a v 
 
 O p t i o n   S p e e d   9 
 
 
 
 C o n t r o l s   O p e n T e x t B o x   
 
 
 
 v 1   =   1 2   ' 4     '   < - - -   W r i t e   h e r e   t h e   C O M - P o r t   n u m b e r 
 
 C O M   O p e n   v 1   9 6 0 0 
 
 s 1   =   C O M _ S t a t u s 
 
 s 1   =   " P o r t   s t a t u s :   "   +   s 1   +   "   C O M "   +   v 1   +   C R L F 
 
 s 1   =   s 1   +   " V a l i d   p o r t s :   "   +   C O M _ P o r t N a m e s   +   C R L F   +   C R L F 
 
 P r i n t   s 1 
 
 
 
 B u t t o n     1   T e x t   1 8   F O R E V E R 
 
 B u t t o n     2   T e x t   S e q u e n c e 	 	 '   9 
 
 B u t t o n     3   T e x t   1 2 
 
 B u t t o n     4   T e x t   1 3 
 
 B u t t o n     5   T e x t   1 4 
 
 B u t t o n     6   T e x t   1 5 
 
 B u t t o n     7   T e x t   1 6 
 
 B u t t o n     8   T e x t   1 7 
 
 B u t t o n     9   T e x t   1 8 
 
 B u t t o n   1 0   T e x t   1 9 
 
 B u t t o n   1 1   T e x t   2 2 
 
 B u t t o n   1 2   T e x t   2 6 
 
 
 
 B u t t o n   1 4   T e x t   S T A R T 
 
 B u t t o n   1 5   T e x t   S T O P 
 
 B u t t o n   1 6   T e x t   C L O S E   A L L 
 
 
 
 B u t t o n   1   C o l o r   Y e l l o w 
 
 B u t t o n   2   C o l o r   Y e l l o w 
 
 B u t t o n   3   C o l o r   Y e l l o w G r e e n 
 
 B u t t o n   4   C o l o r   Y e l l o w G r e e n 
 
 B u t t o n   5   C o l o r   Y e l l o w G r e e n 
 
 B u t t o n   6   C o l o r   Y e l l o w G r e e n 
 
 B u t t o n   7   C o l o r   Y e l l o w G r e e n 
 
 B u t t o n   8   C o l o r   Y e l l o w G r e e n 
 
 B u t t o n   9   C o l o r   L a w n G r e e n 
 
 B u t t o n   1 0   C o l o r   Y e l l o w G r e e n 
 
 B u t t o n   1 1   C o l o r   Y e l l o w G r e e n 
 
 B u t t o n   1 2   C o l o r   Y e l l o w G r e e n 
 
 
 
 B u t t o n   1 4   C o l o r   G r e e n 
 
 B u t t o n   1 5   C o l o r   R e d 
 
 B u t t o n   1 6   C o l o r   B l a c k 
 
 
 
 ' L o a d   T h e r e m i n o _ H A L \ T h e r e m i n o _ H A L . e x e 
 
 ' L o a d   . . \ T h e r e m i n o _ T e r m i n a l _ R X \ T h e r e m i n o _ T e r m i n a l . e x e 
 
 ' L o a d   . . \ T h e r e m i n o _ T e r m i n a l _ T X \ T h e r e m i n o _ T e r m i n a l . e x e 
 
 ' L o a d   . . \ T h e r e m i n o _ H A L \ T h e r e m i n o _ S l o t V i e w e r . e x e 
 
 ' L o a d   . . \ T h e r e m i n o _ H A L \ T h e r e m i n o _ S i g n a l S c o p e . e x e 
 
 
 
 '   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   R e m e m b e r   l a s t   t o t a l s 
 
 L o a d   V a r s 
 
 
 
 ' C o n t r o l s   O p e n T e x t B o x 
 
 
 
 S t o p                                                                                         ' 
 
 
 
 L a b e l   C L O S E   A L L 
 
 	 L o a d   C l o s e A p p s 
 
 R e t u r n 
 
 
 
 L a b e l   E v e n t S t o p 
 
 	 S a v e   V a r s 
 
 E n d                                                                                           ' 
 
 
 
 
 
 L a b e l   1 8   F O R E V E R 
 
 	 s 2   =   " " 
 
 	 F o r   v 1   =   1   T o   9 e 9 9 
 
 	 	 s 1   =   " 1 8 M 4 C W "   +   C R L F 
 
 	 	 C O M   W r i t e S t r i n g   s 1 
 
 	 	 G o s u b   W a i t R e s p o n s e 
 
 	 N e x t 
 
 R e t u r n 
 
 
 
 L a b e l   W a i t R e s p o n s e 
 
 	 F o r   v 2   =   1   T o   1 e 9 9 
 
 	 	 s 2   =   s 2   +   C O M _ R e c e i v e d 
 
 	 	 S e l e c t   s 2 
 
 	 	 	 C a s e   " A K " 
 
 	 	 	 	 s 2   =   " " 
 
 	 	 	 C a s e   " O K " 
 
 	 	 	 	 s 2   =   " " 
 
 	 	 	 	 v 7   =   v 7   +   1 
 
 	 	 	 	 E x i t 
 
 	 	 	 C a s e   " N O " 
 
 	 	 	 	 s 2   =   " " 
 
 	 	 	 	 L o a d   " s i r e n a . w a v " 
 
 	 	 	 	 W a i t   S e c o n d s   2 
 
 	 	 	 	 v 8   =   v 8   +   1 
 
 	 	 	 	 v 7   =   v 7   +   1 
 
 	 	 	 	 E x i t 
 
 	 	 E n d S e l e c t 
 
 	 N e x t 
 
 	 P r i n t   "   T e s t   n u m :   "   +   v 7   +   "   E r r o r s :   "   +   v 8   +   C R L F 
 
 	 W a i t   S e c o n d s   0 . 1 
 
 R e t u r n 
 
 
 
 L a b e l   9 
 
 	 s 1   =   " 9 M 4 C W "   +   C R L F 
 
 	 W a i t   S e c o n d s   0 . 0 2 
 
 	 C O M   W r i t e S t r i n g   s 1 
 
 	 P r i n t   s 1 
 
 R e t u r n 
 
 
 
 L a b e l   1 2 
 
 	 s 1   =   " 1 2 M 4 C W "   +   C R L F 
 
 	 W a i t   S e c o n d s   0 . 0 2 
 
 	 C O M   W r i t e S t r i n g   s 1 
 
 	 P r i n t   s 1 
 
 R e t u r n 
 
 
 
 L a b e l   1 3 
 
 	 s 1   =   " 1 3 M 4 C W "   +   C R L F 
 
 	 W a i t   S e c o n d s   0 . 0 2 
 
 	 C O M   W r i t e S t r i n g   s 1 
 
 	 P r i n t   s 1 
 
 R e t u r n 
 
 
 
 L a b e l   1 4 
 
 	 s 1   =   " 1 4 M 4 C W "   +   C R L F 
 
 	 W a i t   S e c o n d s   0 . 0 2 
 
 	 C O M   W r i t e S t r i n g   s 1 
 
 	 P r i n t   s 1 
 
 R e t u r n 
 
 
 
 L a b e l   1 5 
 
 	 s 1   =   " 1 5 M 4 C W "   +   C R L F 
 
 	 W a i t   S e c o n d s   0 . 0 2 
 
 	 C O M   W r i t e S t r i n g   s 1 
 
 	 P r i n t   s 1 
 
 R e t u r n 
 
 
 
 L a b e l   1 6 
 
 	 s 1   =   " 1 6 M 4 C W "   +   C R L F 
 
 	 W a i t   S e c o n d s   0 . 0 2 
 
 	 C O M   W r i t e S t r i n g   s 1 
 
 	 P r i n t   s 1 
 
 R e t u r n 
 
 
 
 L a b e l   1 7 
 
 	 s 1   =   " 1 7 M 4 C W "   +   C R L F 
 
 	 W a i t   S e c o n d s   0 . 0 2 
 
 	 C O M   W r i t e S t r i n g   s 1 
 
 	 P r i n t   s 1 
 
 R e t u r n 
 
 
 
 L a b e l   1 8 
 
 	 s 1   =   " 1 8 M 4 C W "   +   C R L F 
 
 	 W a i t   S e c o n d s   0 . 0 2 
 
 	 C O M   W r i t e S t r i n g   s 1 
 
 	 P r i n t   s 1 
 
 R e t u r n 
 
 
 
 L a b e l   1 9 
 
 	 s 1   =   " 1 9 M 4 C W "   +   C R L F 
 
 	 W a i t   S e c o n d s   0 . 0 2 
 
 	 C O M   W r i t e S t r i n g   s 1 
 
 	 P r i n t   s 1 
 
 R e t u r n 
 
 
 
 L a b e l   2 2 
 
 	 s 1   =   " 2 2 M 4 C W "   +   C R L F 
 
 	 W a i t   S e c o n d s   0 . 0 2 
 
 	 C O M   W r i t e S t r i n g   s 1 
 
 	 P r i n t   s 1 
 
 R e t u r n 
 
 
 
 L a b e l   2 6 
 
 	 s 1   =   " 2 6 M 4 C W "   +   C R L F 
 
 	 W a i t   S e c o n d s   0 . 0 2 
 
 	 C O M   W r i t e S t r i n g   s 1 
 
 	 P r i n t   s 1 
 
 R e t u r n 
 
 
 
 L a b e l   S T A R T 
 
 	 S l o t ( 1 4 )   =   1 0 0 0 	 	 ' s h o w   s t a r t   s i g n a l 
 
 	 s 1   =   " S T A R T "   +   C R L F 
 
 	 W a i t   S e c o n d s   0 . 0 2 
 
 	 C O M   W r i t e S t r i n g   s 1 
 
 	 P r i n t   s 1 
 
 	 S l o t ( 1 4 )   =   0 	 	 ' s h o w   s t o p   s i g n a l 
 
 R e t u r n 
 
 
 
 L a b e l   2 0 M 4 C W 
 
 	 S l o t ( 1 4 )   =   1 0 0 0 	 	 ' s h o w   s t a r t   s i g n a l 
 
 	 s 1   =   " 2 0 M 4 C W "   +   C R L F 
 
 	 W a i t   S e c o n d s   0 . 0 2 
 
 	 C O M   W r i t e S t r i n g   s 1 
 
 	 P r i n t   s 1 
 
 	 S l o t ( 1 4 )   =   0 	 	 ' s h o w   s t o p   s i g n a l 
 
 R e t u r n 
 
 
 
 L a b e l   2 M 4 C C W 	 	 	 ' s h o w   s t a r t   s i g n a l 
 
 	 S l o t ( 1 4 )   =   1 0 0 0 
 
 	 s 1   =   " 2 M 4 C C W "   +   C R L F 
 
 	 ' W a i t   S e c o n d s   0 . 0 2 
 
 	 C O M   W r i t e S t r i n g   s 1 
 
 	 P r i n t   s 1 
 
 	 S l o t ( 1 4 )   =   0 	 	 ' s h o w   s t o p   s i g n a l 
 
 R e t u r n 
 
 
 
 L a b e l   S T O P 	 	           	 ' s h o w   s t a r t   s i g n a l 
 
 	 S l o t ( 1 4 )   =   1 0 0 0   +   C R L F 
 
 	 ' W a i t   S e c o n d s   0 . 0 2 
 
 	 s 1   =   " S T O P "   +   C R L F 
 
 	 C O M   W r i t e S t r i n g   s 1 
 
 	 P r i n t   s 1 
 
 	 S l o t ( 1 4 )   =   0 	 	 ' s h o w   s t o p   s i g n a l 
 
 R e t u r n 
 
 
 
 
 
 '   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 '     S E Q U E N C E   S T A R T 
 
 '   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 L a b e l   S e q u e n c e 
 
 	 S e q u e n c e F i l e N a m e   =   " S E Q U E N C E S \ A l l S c r e w s . s e q " 
 
 	 G o s u b   E x e c S e q u e n c e 
 
 R e t u r n 
 
 
 
 '   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 '     S E Q U E N C E   L O A D I N G   A N D   E X E C U T I O N 
 
 '   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 V a r i a b l e   S t r i n g   S e q u e n c e F i l e N a m e 
 
 V a r i a b l e   S t r i n g   S e q u e n c e 
 
 V a r i a b l e   S t r i n g   S e q u e n c e C m d 
 
 V a r i a b l e   N u m e r i c   S e q u e n c e I n d e x 
 
 V a r i a b l e   N u m e r i c   S e q u e n c e L e n g t h 
 
 
 
 L a b e l   E x e c S e q u e n c e 
 
 	 L o a d   S e q u e n c e   S e q u e n c e F i l e N a m e 
 
 	 I f   L e n ( S e q u e n c e )   =   0 
 
 	 	 C o n t r o l s   O p e n T e x t B o x 
 
 	 	 P r i n t   C R L F   +   "   S e q u e n c e   f i l e   n o t   f o u n d :   "   +   S e q u e n c e F i l e N a m e 
 
 	 	 B e e p 
 
 	 	 S t o p 
 
 	 E n d I f 
 
 	 '   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 
 	 V a r i a b l e   N u m e r i c   E x e c S e q u e n c e S t a r t T i m e 
 
 	 E x e c S e q u e n c e S t a r t T i m e   =   E l a p s e d T i m e 
 
 	 '   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 
 	 S e q u e n c e L e n g t h   =   G e t S e p a r a t e d S t r i n g C o u n t ( S e q u e n c e ,   C R L F ) 
 
 	 F o r   S e q u e n c e I n d e x   =   0   T o   S e q u e n c e L e n g t h - 1 
 
 	 	 S e q u e n c e C m d   =   G e t S e p a r a t e d S t r i n g ( S e q u e n c e ,   S e q u e n c e I n d e x ,   C R L F ) 
 
 	 	 S e q u e n c e C m d   =   R e p l a c e ( S e q u e n c e C m d ,   C h r ( 9 ) ,   "   " )   ' T A B S   t o   S P A C E S 
 
 	 	 S e q u e n c e C m d   =   R e m o v e C o m m e n t s ( S e q u e n c e C m d ) 
 
 	 	 S e q u e n c e C m d   =   T r i m ( S e q u e n c e C m d ) 
 
 	 	 ' 
 
 	 	 I f   S e q u e n c e C m d   < >   " " 
 
 	 	 	 P r i n t   "   E x e c u t i n g   c o m m a n d :   "   +   S e q u e n c e C m d   +   C R L F 
 
 	 	 E n d I f 
 
 	 	 ' 
 
 	 	 S e l e c t   U C a s e ( S e q u e n c e C m d ) 
 
                         '   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   E n d   s e q u e n c e 
 
 	 	 	 C a s e   " E N D S E Q " 
 
 	 	 	 	 E x i t 
 
 	 	         '   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   A C T I O N S 
 
 	 	 	 C a s e   " C L O S E   A L L " 
 
 	 	 	 	 G o s u b   C L O S E   A L L 
 
 	 	 	 '   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   L E D   C O L O R S 
 
 	 	 	 ' C a s e   " R E D O N " 
 
 	 	 	 ' 	 G o s u b   R e d O n 
 
 	 	 	 ' C a s e   " G R E E N O N " 
 
 	 	 	 ' 	 G o s u b   G r e e n O n 
 
 	 	 	 ' C a s e   " B L U O N " 
 
 	 	 	 ' 	 G o s u b   B l u O N 
 
 	 	 	 ' C a s e   " Y E L L O W O N " 
 
 	 	 	 ' 	 G o s u b   Y e l l o w O n 
 
                         '   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   W i t h   p a r a m e t e r s 
 
 	 	 	 C a s e E l s e 
 
 	 	 	 	 s 1   =   G e t S e p a r a t e d S t r i n g ( S e q u e n c e C m d ,   0 ) 
 
 	 	 	 	 S e l e c t   U C a s e ( s 1 ) 
 
 	 	 	 	 	 C a s e   " S C R E W " 
 
 	 	 	 	 	 	 s 1   =   G e t S e p a r a t e d S t r i n g ( S e q u e n c e C m d ,   1 )   +   C R L F 
 
 	 	 	 	 	 	 C O M   W r i t e S t r i n g   s 1 
 
 	 	 	 	 	 	 G o s u b   W a i t R e s p o n s e 
 
 	 	 	 	 	 C a s e E l s e 
 
 	 	 	 	 	 	 I f   s 1   < >   " " 
 
 	 	 	 	 	 	 	 C o n t r o l s   O p e n T e x t B o x 
 
 	 	 	 	 	 	 	 P r i n t   C R L F   +   "   U n r e c o g n i z e d   c o m m a n d :   "   +   S e q u e n c e C m d   +   C R L F 
 
 	 	 	 	 	 	 	 B e e p 
 
 	 	 	 	 	 	 	 S t o p 
 
 	 	 	 	 	 	 E n d I f 
 
 	 	 	 	 E n d S e l e c t 
 
 	 	 E n d S e l e c t 
 
 	 N e x t 
 
 	 S e q u e n c e F i l e N a m e   =   R e p l a c e ( S e q u e n c e F i l e N a m e , " . s e q " , " " ) 
 
 	 P r i n t   S e q u e n c e F i l e N a m e   +   "   e x e c u t e d   i n   "   +   F o r m a t ( E l a p s e d T i m e   -   E x e c S e q u e n c e S t a r t T i m e ,   " 0 . 0 0 " )   +   "   s e c o n d s " 
 
 R e t u r n 
 
 
 
 
 
 ' W A T C H   C O M _ S t a t u s 
 
 